<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="mini"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="一级类目" prop="oneCategoryId">
        <el-select
          v-model="queryParams.oneCategoryId"
          @change="changeOne"
          placeholder="请选择"
        >
          <el-option label="请选择" :value="null"></el-option>
          <el-option
            v-for="(item, index) in categoryList1"
            :key="index"
            :label="item.categoryName"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级类目" prop="twoCategoryId">
        <el-select
          v-model="queryParams.twoCategoryId"
          @change="changeTwo"
          placeholder="请选择"
        >
          <el-option label="请选择" :value="null"></el-option>
          <el-option
            v-for="(item, index) in categoryList2"
            :key="index"
            :label="item.categoryName"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级类目" prop="threeCategoryId">
        <el-select v-model="queryParams.threeCategoryId" placeholder="请选择">
          <el-option label="请选择" :value="null"></el-option>
          <el-option
            v-for="(item, index) in categoryList3"
            :key="index"
            :label="item.categoryName"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label-width="40" label="ID" prop="id">
        <el-input
          type="number"
          v-model="queryParams.id"
          placeholder="ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="标号名称" prop="name">
        <el-input
          v-model.trim="queryParams.name"
          placeholder="请输入标号名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:designator:add']"
          >新增</el-button
        >
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="designatorList"
      @selection-change="handleSelectionChange"
      :header-cell-style="{ backgroundColor: '#F7F8FA' }"
      height="380"
    >
      <el-table-column
        fixed="left"
        type="selection"
        width="55"
        align="center"
      />
      <el-table-column label="ID" width="55" align="center" prop="id" />
      <el-table-column
        label="主标号名称"
        width="150"
        align="center"
        prop="name"
        show-overflow-tooltip
      />
      <el-table-column label="强度等级" align="center" prop="intensityRating" />
      <!-- <el-table-column label="123目录联动id" align="center" prop="categoryInfoId" />
      
      <el-table-column label="保塑时间/h" align="center" prop="plasticHoldingTime" />
      <el-table-column label="强度等级(数字)" align="center" prop="intensityRating" /> -->
      <el-table-column label="基准价格" align="center" prop="benchmarkPrice" />
      <el-table-column
        label="一级类目(类别)"
        width="150"
        align="center"
        prop="oneCategoryName"
        show-overflow-tooltip
      />
      <el-table-column
        label="二级类目(品类)"
        width="150"
        align="center"
        prop="twoCategoryName"
        show-overflow-tooltip
      />
      <el-table-column
        label="三级类目(品名)"
        width="150"
        align="center"
        prop="threeCategoryName"
        show-overflow-tooltip
      />
      <!-- <el-table-column label="html内容" align="center" prop="content" /> -->
      <!-- <el-table-column label="状态0开1关" align="center" prop="status" /> -->
      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <el-switch
            :value="scope.row.status == '0'"
            @change="changeStatus(scope.row)"
          ></el-switch>
        </template>
      </el-table-column>
      <el-table-column
        width="160px"
        fixed="right"
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            >详情</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:designator:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:designator:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改产品--主标号对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1000px"
      append-to-body
      :before-close="handleClose"
      :close-on-click-modal="false"
    >
      <el-tabs type="border-card" v-model="activeName">
        <el-tab-pane label="①选择类目" name="1">
          <el-card>
            <el-form
              ref="form-left"
              label-position="top"
              :model="form"
              :rules="rules"
              label-width="80px"
              :disabled="editDisabled"
            >
              <el-row>
                <el-col :span="8">
                  <el-form-item label="一级类目:" prop="oneCategoryId">
                    <el-select
                      style="width: 100%"
                      @change="formChangeOne"
                      v-model="form.oneCategoryId"
                      placeholder="请选择一级类目"
                      v-if="!editDisabled"
                    >
                      <el-option
                        v-for="(item, index) in formCategoryList1"
                        :key="index"
                        :label="item.categoryName"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                    <span v-else>{{ form.oneCategoryName }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="二级类目:" prop="twoCategoryId">
                    <el-select
                      style="width: 220px"
                      @change="formChangeTwo"
                      v-model="form.twoCategoryId"
                      placeholder="请选择二级类目"
                      v-if="!editDisabled"
                    >
                      <el-option
                        v-for="(item, index) in formCategoryList2"
                        :key="index"
                        :label="item.categoryName"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                    <span v-else>{{ form.twoCategoryName }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="三级类目:" prop="threeCategoryId">
                    <el-select
                      style="width: 220px"
                      @change="formChangeThree"
                      v-model="form.threeCategoryId"
                      placeholder="请选择三级类目"
                      v-if="!editDisabled"
                    >
                      <el-option
                        v-for="(item, index) in formCategoryList3"
                        :key="index"
                        :label="item.categoryName"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                    <span v-else>{{ form.threeCategoryName }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-card>
          <el-card style="margin-top: 10px">
            <el-form
              ref="form-type"
              :model="form"
              :rules="rules"
              label-position="top"
              :disabled="editDisabled"
            >
              <el-form-item label="选择表单:" prop="type">
                <el-select
                  v-model="form.type"
                  placeholder="请选择"
                  v-if="!editDisabled"
                >
                  <el-option label="预拌混凝土" :value="'1'"></el-option>
                  <el-option label="预拌砂浆" :value="'2'"></el-option>
                </el-select>
                <span v-else>{{
                  form.type == 1
                    ? "预拌混凝土"
                    : form.type == 2
                    ? "预拌砂浆"
                    : ""
                }}</span>
              </el-form-item>
            </el-form>
          </el-card>
        </el-tab-pane>
        <el-tab-pane label="②填写信息" name="2" v-if="form.type == 1">
          <el-form
            class="form-right"
            ref="form-right"
            :model="{ ...form, ...form1 }"
            :rules="rules"
            label-width="100px"
            label-position="left"
            :disabled="editDisabled"
          >
            <el-card>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="主标号名称:"
                    prop="name"
                  >
                    <el-input
                      v-model="form.name"
                      placeholder="请输入主标号名称"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form.name }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label-width="240px" label="状态:" prop="status">
                    <el-switch
                      :value="form.status == '0'"
                      @change="
                        (value) => {
                          form.status = value ? '0' : '1';
                        }
                      "
                      v-if="!editDisabled"
                    ></el-switch>
                    <span v-else>{{
                      form.status == "0" ? "启用" : "关闭"
                    }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    style="margin-bottom: 0px"
                    label="强度等级:"
                    prop="intensityRating"
                  >
                    <el-input
                      v-model="form.intensityRating"
                      placeholder="请填写强度等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form.intensityRating ? form.intensityRating : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <NumberFormItem
                    labelWidth="240px"
                    requiredMessage="请填写基准价格"
                    style="margin-bottom: 0px"
                    label="基准价格:"
                    prop="benchmarkPrice"
                    errorTip="基准价格不能为负数"
                  >
                    <el-input
                      type="number"
                      v-model="form.benchmarkPrice"
                      placeholder="请填写基准价格"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form.benchmarkPrice ? form.benchmarkPrice : "——"
                    }}</span>
                  </NumberFormItem>
                </el-col>
              </el-row>
            </el-card>
            <el-card style="margin-top: 10px">
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    class="label-right"
                    label="品类代号:"
                    prop="pldh"
                  >
                    <el-input
                      v-model="form1.pldh"
                      placeholder="请填写品类代号"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.pldh ? form1.pldh : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="品名代号:"
                    prop="pmdh"
                  >
                    <el-input
                      v-model="form1.pmdh"
                      placeholder="请填写品名代号"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.pmdh ? form1.pmdh : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    class="label-right"
                    label="表观密度(kg/m3):"
                    prop="bgmd"
                  >
                    <el-input
                      v-model="form1.bgmd"
                      placeholder="请填写表观密度"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.bgmd ? form1.bgmd : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="坍落度与扩展度等级:"
                    prop="dldykzddj"
                  >
                    <el-input
                      v-model="form1.dldykzddj"
                      placeholder="请填写坍落度与扩展度等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form1.dldykzddj ? form1.dldykzddj : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    class="label-right"
                    label-width="240px"
                    label="扩展度等级与扩展直径:"
                    prop="kzddjykzzj"
                  >
                    <el-input
                      v-model="form1.kzddjykzzj"
                      placeholder="请填写扩展度等级与扩展直径"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form1.kzddjykzzj ? form1.kzddjykzzj : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="抗冻等级(快冻法):"
                    prop="kdf"
                  >
                    <el-input
                      v-model="form1.kdf"
                      placeholder="请填写抗冻等级(快冻法)"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.kdf ? form1.kdf : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    class="label-right"
                    label-width="240px"
                    label="抗冻等级(慢冻法):"
                    prop="mdf"
                  >
                    <el-input
                      v-model="form1.mdf"
                      placeholder="请填写抗冻等级(慢冻法)"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.mdf ? form1.mdf : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="抗渗等级:"
                    prop="ksdj"
                  >
                    <el-input
                      v-model="form1.ksdj"
                      placeholder="请填写抗渗等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.ksdj ? form1.ksdj : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    class="label-right"
                    label-width="240px"
                    label="抗硫酸盐等级:"
                    prop="klsydj"
                  >
                    <el-input
                      v-model="form1.klsydj"
                      placeholder="请填写抗硫酸盐等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.klsydj ? form1.klsydj : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="抗氯离子渗透等级[(84d)RCM法]:"
                    prop="kllzstdj"
                  >
                    <el-input
                      v-model="form1.kllzstdj"
                      placeholder="请填写抗氯离子渗透等级[(84d)RCM法]"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form1.kllzstdj ? form1.kllzstdj : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    class="label-right"
                    label-width="240px"
                    label="抗氯离子渗透等级[电通量法(QS/C)]:"
                    prop="kllzstdjdtlf"
                  >
                    <el-input
                      v-model="form1.kllzstdjdtlf"
                      placeholder="请填写抗氯离子渗透等级[电通量法(QS/C)]"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form1.kllzstdjdtlf ? form1.kllzstdjdtlf : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    class="label-right"
                    label-width="240px"
                    label="抗碳化性能等级:"
                    prop="kthxndj"
                  >
                    <el-input
                      v-model="form1.kthxndj"
                      placeholder="请填写抗碳化性能等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form1.kthxndj ? form1.kthxndj : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    class="label-right"
                    label-width="240px"
                    label="自密实性能等级与性能:"
                    prop="zmsxndjyxn"
                  >
                    <el-input
                      v-model="form1.zmsxndjyxn"
                      placeholder="请填写自密实性能等级与性能"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form1.zmsxndjyxn ? form1.zmsxndjyxn : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="透水系数:"
                    prop="tsxs"
                  >
                    <el-input
                      v-model="form1.tsxs"
                      placeholder="请填写透水系数"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.tsxs ? form1.tsxs : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    class="label-right"
                    label="抗折等级:"
                    prop="kzdj"
                  >
                    <el-input
                      v-model="form1.kzdj"
                      placeholder="请填写抗折等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.kzdj ? form1.kzdj : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="干密度等级:"
                    prop="gmddj"
                  >
                    <el-input
                      v-model="form1.gmddj"
                      placeholder="请填写干密度等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.gmddj ? form1.gmddj : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    class="label-right"
                    label="吸水率等级:"
                    prop="xsldj"
                  >
                    <el-input
                      v-model="form1.xsldj"
                      placeholder="请填写吸水率等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.xsldj ? form1.xsldj : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="防火等级:"
                    prop="fhdj"
                  >
                    <el-input
                      v-model="form1.fhdj"
                      placeholder="请填写防火等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form1.fhdj ? form1.fhdj : "——" }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-card>

            <el-card style="margin-top: 10px">
              <el-form-item label-width="240px" label="备注:" prop="remark">
                <el-input
                  v-model="form.remark"
                  type="textarea"
                  placeholder="请输入内容"
                  v-if="!editDisabled"
                />
                <span v-else>{{ form.remark ? form.remark : "——" }}</span>
              </el-form-item>
            </el-card>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="②填写信息" name="3" v-if="form.type == 2">
          <el-form
            class="form-right"
            ref="form-right"
            :model="{ ...form, ...form2 }"
            :rules="rules"
            label-position="left"
            label-width="90px"
            :disabled="editDisabled"
          >
            <el-card>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="主标号名称:"
                    prop="name"
                  >
                    <el-input
                      v-model="form.name"
                      placeholder="请输入主标号名称"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form.name }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label-width="240px" label="状态:" prop="status">
                    <el-switch
                      :value="form.status == '0'"
                      @change="
                        (value) => {
                          form.status = value ? '0' : '1';
                        }
                      "
                      v-if="!editDisabled"
                    ></el-switch>
                    <span v-else>{{
                      form.status == "0" ? "启用" : "关闭"
                    }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <NumberFormItem
                    labelWidth="240px"
                    requiredMessage="请填写保塑时间"
                    label="保塑时间:"
                    prop="plasticHoldingTime"
                    errorTip="保塑时间不能为负数"
                  >
                    <el-input
                      type="number"
                      v-model="form.plasticHoldingTime"
                      placeholder="请填写保塑时间"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form.plasticHoldingTime ? form.plasticHoldingTime : "——"
                    }}</span>
                  </NumberFormItem>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="强度等级:"
                    prop="intensityRating"
                  >
                    <el-input
                      v-model="form.intensityRating"
                      placeholder="请填写强度等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form.intensityRating ? form.intensityRating : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <NumberFormItem
                    labelWidth="240px"
                    label="基准价格:"
                    requiredMessage="基准价格"
                    prop="benchmarkPrice"
                    errorTip="基准价格不能为负数"
                  >
                    <el-input
                      type="number"
                      v-model="form.benchmarkPrice"
                      placeholder="基准价格"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form.benchmarkPrice ? form.benchmarkPrice : "——"
                    }}</span>
                  </NumberFormItem>
                </el-col>
              </el-row>
            </el-card>
            <el-card style="margin-top: 10px">
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="品类代号:"
                    prop="pldh"
                  >
                    <el-input
                      v-model="form2.pldh"
                      placeholder="请填写品类代号"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form2.pldh ? form2.pldh : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="品名代号:"
                    prop="pmdh"
                  >
                    <el-input
                      v-model="form2.pmdh"
                      placeholder="请填写品名代号"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form2.pmdh ? form2.pmdh : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="表观密度(kg/m3):"
                    prop="bgmd"
                  >
                    <el-input
                      v-model="form2.bgmd"
                      placeholder="请填写表观密度"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form2.bgmd ? form2.bgmd : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label-width="240px" label="稠度n/mm:" prop="cd">
                    <el-input
                      v-model="form2.cd"
                      placeholder="请填写稠度"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form2.cd ? form2.cd : "——" }}</span>
                  </el-form-item>
                </el-col>

                <el-col :span="12">
                  <el-form-item label-width="240px" label="保水率%:" prop="bsl">
                    <el-input
                      v-model="form2.bsl"
                      placeholder="请填写保水率"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form2.bsl ? form2.bsl : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="抗冻性(强度损失率)%:"
                    prop="kdxqdssl"
                  >
                    <el-input
                      v-model="form2.kdxqdssl"
                      placeholder="请填写抗冻性(强度损失率)"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form2.kdxqdssl ? form2.kdxqdssl : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="抗冻性(质量损失率)%:"
                    prop="kdxzlssl"
                  >
                    <el-input
                      v-model="form2.kdxzlssl"
                      placeholder="请填写抗冻性(质量损失率)"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{
                      form2.kdxzlssl ? form2.kdxzlssl : "——"
                    }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="14d粘结拉升强度/MPa:"
                    prop="njlsqd"
                  >
                    <el-input
                      v-model="form2.njlsqd"
                      placeholder="请填写14d粘结拉升强度"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form2.njlsqd ? form2.njlsqd : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="28d收缩率%:"
                    prop="ssl"
                  >
                    <el-input
                      v-model="form2.ssl"
                      placeholder="请填写28d收缩率"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form2.ssl ? form2.ssl : "——" }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label-width="240px"
                    label="抗渗等级:"
                    prop="ksdj"
                  >
                    <el-input
                      v-model="form2.ksdj"
                      placeholder="请填写抗渗等级"
                      v-if="!editDisabled"
                    />
                    <span v-else>{{ form2.ksdj ? form2.ksdj : "——" }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-card>

            <el-card style="margin-top: 10px">
              <el-form-item label-width="240px" label="备注:" prop="remark">
                <el-input
                  v-model="form.remark"
                  type="textarea"
                  placeholder="请输入内容"
                  v-if="!editDisabled"
                />
                <span v-else>{{ form.remark ? form.remark : "——" }}</span>
              </el-form-item>
            </el-card>
          </el-form>
        </el-tab-pane>
      </el-tabs>
      <div slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          v-if="form.type && activeName == '1'"
          @click="activeName = form.type == 1 ? '2' : '3'"
          >下一步</el-button
        >
        <el-button
          v-if="activeName == '2' || activeName == '3'"
          @click="activeName = '1'"
          >上一步</el-button
        >
        <el-button
          type="primary"
          v-if="(!editDisabled && activeName == '2') || activeName == '3'"
          @click="submitForm"
          >提 交</el-button
        >
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listDesignator,
  getDesignator,
  delDesignator,
  addDesignator,
  updateDesignator,
} from "@/api/service/main";
import NumberFormItem from "@/components/NumberFormItem";
import { listOnInfo } from "@/api/service/info";
import { number } from "echarts";
export default {
  components: {
    NumberFormItem,
  },
  name: "Designator",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产品--主标号表格数据
      designatorList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: null,
        name: null,
        oneCategoryId: null,
        twoCategoryId: null,
        threeCategoryId: null,
      },
      // 表单参数
      form: {},
      form1: {}, // 预拌混凝土
      form2: {}, // 预拌砂浆

      // 表单校验
      rules: {
        oneCategoryId: [
          { required: true, message: "请选择一级类目", trigger: "change" },
        ],
        twoCategoryId: [
          { required: true, message: "请选择二级类目", trigger: "change" },
        ],
        threeCategoryId: [
          { required: true, message: "请选择三级类目", trigger: "change" },
        ],
        type: [
          { required: true, message: "请选择表单类型", trigger: "change" },
        ],
        name: [
          {
            required: true,
            message: "主标号名称不能为空",
            trigger: "blur",
          },
        ],
        status: [{ required: true, message: "请选择", trigger: "change" }],
        intensityRating: [
          {
            required: true,
            message: "强度等级不能为空",
            trigger: "blur",
          },
          {
            validator: (rule, value, callback) => {
              if (+value < 0) {
                callback(new Error("强度等级不能为负数"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          },
        ],
      },

      activeName: "1",
      categoryList1: [],
      categoryList2: [],
      categoryList3: [],

      formCategoryList1: [],
      formCategoryList2: [],
      formCategoryList3: [],
      editDisabled: false,
    };
  },
  created() {
    this.getList();
    this.getListOnInfo();
    // 需要添加不可为负数的检验字段
    const numberRules = [
      "bgmd",
      "dldykzddj",
      "kzddjykzzj",
      "kdf",
      "mdf",
      "ksdj",
      "klsydj",
      "kllzstdj",
      "kllzstdjdtlf",
      "kthxndj",
      "zmsxndjyxn",
      "tsxs",
      "kzdj",
      "gmddj",
      "xsldj",
      "fhdj",
      "cd",
      "bsl",
      "kdxqdssl",
      "kdxzlssl",
      "njlsqd",
      "ssl",
      "ksdj",
    ];
    numberRules.forEach((item) => {
      this.rules[item] = [
        {
          validator: (rule, value, callback) => {
            console.log(rule);
            if (Object.is(Number(value), NaN)) {
              callback(new Error("请输入数字"));
            }
            if (+value < 0) {
              callback(new Error("不能为负数"));
            } else {
              callback();
            }
          },
          trigger: "blur",
        },
      ];
    });
  },
  methods: {
    // 开关
    changeStatus(item) {
      const form = { ...item };

      // 改变状态
      form.status = form.status == "0" ? 1 : 0;

      updateDesignator(form).then((response) => {
        this.$modal.msgSuccess("修改成功");
        item.status = form.status;
        //this.getList();
      });
    },
    formChangeOne() {
      this.form.twoCategoryId = null;
      this.form.threeCategoryId = null;
      this.formCategoryList2 = [];
      this.formCategoryList3 = [];
      if (!this.form.oneCategoryId) {
        return;
      }
      listOnInfo({
        type: 2,
        oneCategoryId: this.form.oneCategoryId,
      }).then((response) => {
        this.formCategoryList2 = response.data;
      });
    },
    formChangeTwo() {
      this.form.threeCategoryId = null;
      this.formCategoryList3 = [];
      if (!this.form.twoCategoryId) {
        return;
      }
      listOnInfo({
        type: 3,
        oneCategoryId: this.form.oneCategoryId,
        twoCategoryId: this.form.twoCategoryId,
      }).then((response) => {
        this.formCategoryList3 = response.data;
      });
    },
    formChangeThree() {
      this.form.categoryInfoId = this.formCategoryList3.find(
        (item) => item.id == this.form.threeCategoryId
      )?.categoryInfoId;
      //    this.form.categoryInfoId = this.form.threeCategoryId;
    },
    changeOne() {
      this.queryParams.twoCategoryId = null;
      this.queryParams.threeCategoryId = null;
      this.categoryList2 = [];
      this.categoryList3 = [];
      if (!this.queryParams.oneCategoryId) {
        return;
      }
      listOnInfo({
        type: 2,
        oneCategoryId: this.queryParams.oneCategoryId,
      }).then((response) => {
        this.categoryList2 = response.data;
      });
    },
    changeTwo() {
      this.queryParams.threeCategoryId = null;
      this.categoryList3 = [];
      if (!this.queryParams.twoCategoryId) {
        return;
      }
      listOnInfo({
        type: 3,
        oneCategoryId: this.queryParams.oneCategoryId,
        twoCategoryId: this.queryParams.twoCategoryId,
      }).then((response) => {
        this.categoryList3 = response.data;
      });
    },
    // 查询 一级 二级 三级 目录数据
    getListOnInfo() {
      listOnInfo({ type: 1 }).then((res) => {
        this.categoryList1 = res.data;
        this.formCategoryList1 = res.data;
      });
    },
    /** 查询产品--主标号列表 */
    getList() {
      this.loading = true;
      listDesignator(this.queryParams).then((response) => {
        this.designatorList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.editDisabled = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.activeName = "1";
      this.form = {
        id: null,
        type: null,
        oneCategoryId: null,
        twoCategoryId: null,
        threeCategoryId: null,
        categoryInfoId: null,
        name: null,
        plasticHoldingTime: null,
        intensityRating: null,
        benchmarkPrice: null,
        content: null,
        status: 0,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
      };

      this.form1 = {
        pldh: null,
        pmdh: null,
        bgmd: null,
        dldykzddj: null,
        kzddjykzzj: null,
        kdf: null,
        mdf: null,
        ksdj: null,
        klsydj: null,
        kllzstdj: null,
        kllzstdjdtlf: null,
        kthxndj: null,
        zmsxndjyxn: null,
        tsxs: null,
        kzdj: null,
        gmddj: null,
        xsldj: null,
        fhdj: null,
      };
      this.form2 = {
        pldh: null,
        pmdh: null,
        bgmd: null,
        cd: null,
        bsl: null,
        kdxqdssl: null,
        kdxzlssl: null,
        njlsqd: null,
        ssl: null,
        ksdj: null,
      };

      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增主标号";
    },
    /** 修改按钮操作 */
    handleUpdate(row, title = "修改主标号") {
      this.reset();
      const id = row.id || this.ids;
      getDesignator(id).then((response) => {
        this.form = response.data;

        if (this.form.type == 1) {
          this.form1 = JSON.parse(this.form.content || "{}");
        }
        if (this.form.type == 2) {
          this.form2 = JSON.parse(this.form.content || "{}");
        }

        listOnInfo({
          type: 2,
          oneCategoryId: this.form.oneCategoryId,
        }).then((response) => {
          this.formCategoryList2 = response.data;
        });
        listOnInfo({
          type: 3,
          oneCategoryId: this.form.oneCategoryId,
          twoCategoryId: this.form.twoCategoryId,
        }).then((response) => {
          this.formCategoryList3 = response.data;
        });

        this.open = true;
        this.title = title;
      });
    },
    handleClose() {
      this.editDisabled = false;
      this.cancel();
    },
    /** 详情按钮操作 */
    handleView(row) {
      this.editDisabled = true;
      this.handleUpdate(row, "查看主标号");
    },
    /** 提交按钮 */
    async submitForm() {
      try {
        await this.$refs["form-left"].validate();
      } catch (error) {
        this.activeName = "1";
        return;
      }
      await Promise.all([
        this.$refs["form-type"].validate(),
        this.$refs["form-right"].validate(),
      ]);

      if (this.form.type == 1) {
        this.form.content = JSON.stringify(this.form1);
      }
      if (this.form.type == 2) {
        this.form.content = JSON.stringify(this.form2);
      }

      if (this.form.id != null) {
        updateDesignator(this.form).then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.open = false;
          this.resetQuery();
        });
      } else {
        addDesignator(this.form).then((response) => {
          this.$modal.msgSuccess("新增成功");
          this.open = false;
          this.resetQuery();
        });
      }

      //   this.$refs["form"].validate(valid => {
      //     if (valid) {
      //       if (this.form.id != null) {
      //         updateDesignator(this.form).then(response => {
      //           this.$modal.msgSuccess("修改成功");
      //           this.open = false;
      //           this.getList();
      //         });
      //       } else {
      //         addDesignator(this.form).then(response => {
      //           this.$modal.msgSuccess("新增成功");
      //           this.open = false;
      //           this.getList();
      //         });
      //       }
      //     }
      //   });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除产品--主标号编号为"' + ids + '"的数据项？')
        .then(function () {
          return delDesignator(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/designator/export",
        {
          ...this.queryParams,
        },
        `designator_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>

<style lang="scss" scoped>
.edit-form {
  // display: flex;
  .form-label {
    font-size: 14px;
    font-weight: bold;
    line-height: 36px;
    padding-right: 30px;
    .form-red {
      color: #d23c26;
    }
  }
  .form-value {
    display: flex;
    //gap: 30px;
  }
}

::v-deep .el-tabs__content {
  max-height: 400px;
  overflow: auto;
}

.row-item {
  display: flex;
  // gap: 20px;
}
::v-deep .el-form-item__label {
  // width: 240px;
  text-align: right;
}
.form-right ::v-deep .el-input {
  width: 200px;
}
</style>